#include <cstdio>
#include <climits>
#define OFFSET 2000

int dp[101][4001];
int weight[101];

int main(int argc, char const *argv[]) {
    int times;
    int case_num = 0;
    scanf("%d", &times);
    for (int t = 0; t < times; t++) {
        int n;
        scanf("%d", &n);
        bool weight_zero_exist = false;
        int nonzero_weight_count = 0;
        for (int i = 1; i <= n; i++) {
            scanf("%d", &weight[++nonzero_weight_count]);
            if (weight[nonzero_weight_count] == 0) {
                nonzero_weight_count--;
                weight_zero_exist = true;
            }
        }
        n = nonzero_weight_count;
        for (int i = -2000; i <= 2000; i++)
            dp[0][i + OFFSET] = INT_MIN;
        dp[0][0 + OFFSET] = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = -2000; j <= 2000; j++) {
                int temp_1 = INT_MIN, temp_2 = INT_MIN;
                if (j + weight[i] <= 2000 && dp[i-1][j+weight[i]+OFFSET] != INT_MIN)
                    temp_1 = dp[i-1][j+weight[i]+OFFSET] + weight[i];
                if (j - weight[i] >= -2000 && dp[i-1][j-weight[i]+OFFSET] != INT_MIN)
                    temp_1 = dp[i-1][j-weight[i]+OFFSET] + weight[i];
                    int max_weight = temp_1 > temp_2 ? temp_1 : temp_2;
                    if (max_weight < dp[i-1][j+OFFSET])
                        temp_1 = dp[i-1][j+OFFSET];
                    dp[i][j+OFFSET] = temp_1;    
            }
        }
        printf("Case %d: ", ++case_num);
        if (dp[n][0+OFFSET] == 0)
            puts(weight_zero_exist == true ? "0" : "-1");
        else
            printf("%d\n", dp[n][0+OFFSET] / 2);
    }
    return 0;
}